package com.ct.application.sysrole.service.impl;

import com.ct.application.sysrole.request.SysRoleBindRequest;
import com.ct.application.sysrole.service.ISysUserRolesService;
import com.ct.rbac.repository.ISysUserRolesRespontory;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 用户角色表 服务实现类
 * </p>
 *
 * @author Auto Generator
 * @since 2023-08-13
 */
@Service
public class SysUserRolesServiceImpl implements ISysUserRolesService {

    @Resource
    private ISysUserRolesRespontory sysRoleRolesRespontory;


    /**
     * 根据用户id查询角色列表信息
     * @param userId
     * @return
     */
    @Override
    public List<Long> findUserRoleIds(Long userId){
        return sysRoleRolesRespontory.findUserRoleIds(userId);
    }

    /**
     * 绑定角色
     */
    @Override
    public Boolean saveBindUserRole(SysRoleBindRequest sysRoleBindRequest){
        return  sysRoleRolesRespontory.saveBindUserRole(sysRoleBindRequest.getUserId(),sysRoleBindRequest.getRoleId());
    }

    /**
     * 取消绑定
     */
    @Override
    public Boolean  cancleBindUserRole(SysRoleBindRequest sysRoleBindRequest){
        return  sysRoleRolesRespontory.cancleBindUserRole(sysRoleBindRequest.getUserId(),sysRoleBindRequest.getRoleId());
    }
}

